package com.diploma.interaction.service.impl;

import com.diploma.interaction.mapper.WxxcxWzMapper;
import com.diploma.interaction.model.WxxcxHdxxExample;
import com.diploma.interaction.model.WxxcxWz;
import com.diploma.interaction.model.WxxcxWzExample;
import com.diploma.interaction.service.WzService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Service
@Slf4j
public class WzServiceImpl implements WzService {
    @Resource
    WxxcxWzMapper wxxcxWzMapper;

    @Override
    public int deleteById(int id) {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andWzidEqualTo(BigDecimal.valueOf(id));
        return wxxcxWzMapper.deleteByExample(wzExample);
    }

    @Override
    public void insertSelective(WxxcxWz record) {
        wxxcxWzMapper.insert(record);
    }

    @Override
    public int updateByIdSelective(WxxcxWz record, int id) {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andWzidEqualTo(BigDecimal.valueOf(id));
        return wxxcxWzMapper.updateByExampleSelective(record,wzExample);
    }

    @Override
    public List<WxxcxWz> selectByStaffId(String id) {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andSwryDmEqualTo(id);
        return wxxcxWzMapper.selectByExample(wzExample);
    }

    @Override
    public List<WxxcxWz> selectByZt() {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andZtEqualTo((short) 1);
        return wxxcxWzMapper.selectByExample(wzExample);
    }

    @Override
    public List<WxxcxWz> selectByStaffIdZt(String staffId) {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andSwryDmEqualTo(staffId).andZtEqualTo((short) 1);
        return wxxcxWzMapper.selectByExample(wzExample);
    }

    @Override
    public WxxcxWz selectById(int wzId) {
        WxxcxWzExample wzExample=new WxxcxWzExample();
        wzExample.createCriteria().andWzidEqualTo(BigDecimal.valueOf(wzId));
        return wxxcxWzMapper.selectByExample(wzExample).get(0);
    }
}
